package com.jerry.base.thread;

import lombok.extern.slf4j.Slf4j;

/**
 * User: Jerry
 * Date: 2024/1/31
 * Time: 21:15
 * Description:
 */
@Slf4j
public class RunnableUsage {

    static class Dog implements Runnable {
        private int times = 0;

        @Override
        public void run() {
            while (true) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                log.info("线程{} => 旺了{}次", Thread.currentThread().getName(), ++times);

                if (times ==10 ) {
                    break;
                }
            }
        }
    }

    public static void main(String[] args) {
        Dog dog = new Dog();
        Thread thread = new Thread(dog);
        thread.start();
    }
}
